/**
 * Created by helin3 on 2017/11/25.
 */
define([
  './themes/lang/' + window.YUFP_SYS_CONFIG.language + '/pages/example/package/elTreeX.js'
], function (require, exports) {
  // page加载完成后调用ready方法
  exports.ready = function (hashCode, data, cite) {
    var height = yufp.custom.viewSize().height;
    // 创建virtual model
    yufp.custom.vue({
      el: '#el_tree_x_demo',
      data: {
        height: height,
        // 属性说明，实际使用时不需要此部分
        currClickNode: '',
        grid: {
          data1: [
            {name: 'data-url', remark: this.$t('elTreeX.sj'), type: 'String', option: '—', default: '—'},
            {name: 'data-id', remark: this.$t('elTreeX.jd'), type: 'String', option: '—', default: 'ID'},
            {name: 'data-label', remark: this.$t('elTreeX.jdwb'), type: 'String', option: '—', default: 'NAME'},
            {name: 'data-pid', remark: this.$t('elTreeX.fjd'), type: 'String', option: '—', default: 'PID'},
            {name: 'data-root', remark: this.$t('elTreeX.gjd'), type: 'String', option: '—', default: '0'},
            {name: 'height', remark: this.$t('elTreeX.sgd'), type: 'Number', option: '—', default: '400'},
            {name: 'root-visible', remark: this.$t('elTreeX.sfzsgjd'), type: 'boolean', option: '—', default: 'true'},

            {name: 'show-checkbox', remark: this.$t('elTreeX.jdsfkbxz'), type: 'boolean', option: '—', default: 'false'}
          ],
          data2: [
            {name: 'getCheckedNodes', remark: this.$t('elTreeX.rjdkbxzjwzfhmqbxzdjdszcdsz'), param: '(leafOnly) 接收一个 boolean 类型的参数，若为 true 则仅返回被选中的叶子节点，默认值为 false'},
            {name: 'setCheckedNodes', remark: this.$t('elTreeX.szmqgxdjd'), param: '(nodes) 接收勾选节点数据的数组'},
            {name: 'getCheckedKeys', remark: this.$t('elTreeX.rjdkbxzjwzfhmqbxzdjdszcdsz'), param: '(leafOnly) 接收一个 boolean 类型的参数，若为 true 则仅返回被选中的叶子节点的 keys，默认值为 false'},
            {name: 'setCheckedKeys', remark: this.$t('elTreeX.tgszmqgxdjd'), param: '(keys, leafOnly) 接收两个参数，1. 勾选节点的 key 的数组 2. boolean 类型的参数，若为 true 则仅设置叶子节点的选中状态，默认值为 false'},
            {name: 'setChecked', remark: this.$t('elTreeX.tgszmgjddgxzt'), param: '(key/data, checked, deep) 接收三个参数，1. 勾选节点的 key 或者 data 2. boolean 类型，节点是否选中 3. boolean 类型，是否设置子节点 ，默认为 false'}

          ],
          data3: [
            {name: 'node-click', remark: this.$t('elTreeX.jdbdjsdht'), param: '（nodeData, node, self）'},
            {name: 'check-change', remark: this.$t('elTreeX.jdxzztfsbhsdht'), param: '（nodeData, checked, indeterminate）'},
            {name: 'current-change', remark: this.$t('elTreeX.dqxzjdbhscfdsj'), param: '(nodeData, node, self)'},
            {name: 'node-expand', remark: this.$t('elTreeX.jdbzkscfdsj'), param: '(nodeData, node, instance)'},
            {name: 'node-collapse', remark: this.$t('elTreeX.jdbgbscfdsj'), param: '(nodeData, node, instance)'}
          ]
        }
      },
      methods: {
        nodeClickFn: function (nodeData, node, self) {
          this.currClickNode = nodeData.id + '|' + nodeData.label;
        },
        getCheckedNodes: function () {
          this.$alert(this.$refs.mytree.getCheckedNodes(), this.$t('elTreeX.ts'));
        },
        getCheckedKeys: function () {
          this.$alert(this.$refs.mytree.getCheckedKeys());
        },
        setCheckedKeys: function () {
          this.$refs.mytree.setCheckedKeys(['503']);
        },
        resetChecked: function () {
          this.$refs.mytree.setCheckedKeys([]);
        }
      }
    });
  };

  // 消息处理
  exports.onmessage = function (type, message) {

  };

  // page销毁时触发destroy方法
  exports.destroy = function (id, cite) {

  };
});
